package sale.wxb.loveshopping.utils;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import sale.wxb.loveshopping.entity.vo.common.PageRecord;

public class PageRecordUtil {
    /**
     * 将Page转为PageRecord类
     * @param page mp page类
     * @return PageRecord<T>
     * @param <T> 类型
     */
    public static <T> PageRecord<T> toPageRecord(Page<T> page) {
        PageRecord<T> record = new PageRecord<>();
        record.setRecords(page.getRecords());
        record.setTotal(page.getTotal());
        record.setSize(page.getSize());
        record.setCurrent(page.getCurrent());
        record.setPages(page.getPages());
        return record;
    }
}
